home *** CD-ROM | disk | FTP | other *** search
- program who_am_i;
-
- { ****************************************************************
-
- This program locates its load name. Starting with PC-DOS 3.0,
- DOS records the load name at the end of the environment space:
-
- <environment string><0>
- <environment string><0>
- ...
- <environment string><0>
- <0>
- <1><0>
- <load name><0>
-
- So, to locate the load name we search for the two succesive
- zeroes which terminate the environment string(s), then skip
- tho bytes (<1><0>), then retrieve the load name.
-
- DOS VERSIONS PRIOR TO PC-DOS 3.0
- DO NOT RECORD THE LOAD NAME!
-
- ****************************************************************
-
- May 5, 1986. Compuserve ID: [74166,1524]
- Gary Maltzen. TC/PC: 612-545-5014
- Terrapin Station: 612-623-0152
-
- *************************************************************** }
- {$C+}
- var
- e : integer; { environment segment }
- i : integer; { offset within segment }
- n : integer; { count successive zero bytes }
-
- begin
- e := memw[cseg:$2C]; { get environment segment }
- i := 0; { start at the beginning }
- n := 0; { no zero bytes seen yet }
- repeat
- while mem[e:i] <> 0 do { search a zero byte }
- i := i+1;
- i := i+1;
- until mem[e:i] = 0; { stop at second zero byte }
- i := i+3; { skip to loaded file name }
- while (mem[e:i] <> 0) do { display the load descriptor }
- begin
- write(chr(mem[e:i]));
- i := i+1;
- end;
- writeln;
- end.